<? include ("../init.php") ?>
<? include ("../header.php") ?>
<? include ("../menu.php") ?>
<? include ("submenu.php") ?>

<div id = "body">

<h1><?_l('Category')?></h1>

<a href = "form2.php" class = "add"><img src = "<?=ADMIN?>/images/icon-add.png">&nbsp;&nbsp;&nbsp;<?_l('Add Category')?></a>

<div class = "clear"></div>

<div class = "page">
<?
  $count = $db->countOfAll('hs_category');
  $start = setpage($count);
?>
</div>

<div class = "clear"></div>

<table class ="list">
  <tr>
    <th scope="col"><?_l('category')?></th>
    <th scope="col" width = "50"><?_l('edit')?></th>
    <th scope="col" width = "50"><?_l('delete')?></th>
  </tr>
<?
  $rss = $db->query("SELECT * FROM hs_category ORDER BY c_name LIMIT $start,".PAGE);
  while ($line = $db->fetchNextObject($rss)){
    $pid = $db->queryUniqueValue('SELECT p_id FROM hs_product WHERE c_id='.$line->c_id);
?>
  <tr>
    <td style="text-transform:capitalize;"><?=$line->c_name?></td>
    <td><a href = "edit.php?aid=<?=$line->c_id?>" class = "btn"><?_l('edit')?></a></td>
<?php
    if($pid==NULL OR $pid==''){
?>
    <td><a href = "delete.php?aid=<?=$line->c_id?>" class = "btn" onClick = "return confirmSubmit()"><?_l('delete')?></a></td>
<?php
    }else{
?>
    <td>&nbsp;</td>
<?php
    }
?>
  </tr>
<?
  }
?>
</table>

</div>

<style>

</style>

<? include "../footer.php" ?>